package com.cml.rpc.server;

import com.cml.rpc.publicinterface.BlogService;
import com.cml.rpc.publicinterface.UserService;

import java.util.Map;

/**
 * 服务端入口
 * @author cml
 * @create 2021/7/21 10:14
 */
public class RpcServerMain {
    public static void main(String[] args) {
        UserService userService = new UserServiceImpl();
        BlogService blogService = new BlogServiceImpl();
        //添加服务实现类
/*        Map<String, Object> serverProvider = new HashMap<>();
        serverProvider.put("com.cml.rpc.service.UserService", userService);
        serverProvider.put("com.cml.rpc.service.BlogService", blogService);*/
        ServiceProvider serviceProvider = new ServiceProvider("127.0.0.1", 8877);
        serviceProvider.put(userService);
        serviceProvider.put(blogService);
        Map<String, Object> serverProvider = serviceProvider.getServerProvider();

//        SimpleRpcServer simpleRpcServer = new SimpleRpcServer(serverProvider);
//        simpleRpcServer.start(8877);

        NettyRpcServer nettyRpcServer = new NettyRpcServer(serviceProvider);
        nettyRpcServer.start(8877);
    }
}
